class DictValuesController < ApplicationController
  before_action :set_dict_value, only: [:show, :edit, :update, :destroy]
  # before_action :set_dict
  
  respond_to :html

  def index
    @dict_values = DictValue.all
    respond_with(@dict_values)
  end

  def show
    respond_with(@dict_value)
  end

  def new
    @dict_value = DictValue.new
    respond_with(@dict_value)
  end

  def edit
  end

  def create
    @dict_value = DictValue.new(dict_value_params)
    @dict_value.save
    respond_to do |format|
      if @dict_value.save
        format.html { redirect_to dicts_path, notice: 'Item was successfully created.' }
        format.json { render :show, status: :created, location: @dict_value }
      else
        format.html { render :new }
        format.json { render json: @dict_value.errors, status: :unprocessable_entity }
      end
    end
  end

  def update
    @dict_value.update(dict_value_params)
    respond_with(@dict_value)
  end

  def destroy
    @dict_value.destroy
    respond_with(@dict_value)
  end

  private
    def set_dict_value
      @dict_value = DictValue.find(params[:id])
    end
    
    # def set_dict
      # @dict = Dict.find(params[:dict_id])
    # end

    def dict_value_params
      params.require(:dict_value).permit(:value,:dict_id)
    end
end
